#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#define MAX_SIZE 50
typedef char DataType;
typedef struct SeqList
{
	DataType data[MAX_SIZE];
	int length;
}SList;
void CreateList(SList* &L,DataType arr[],int n)
{
	L = (SList*)malloc(sizeof(SList));
	for (int i=0;i<n;i++)
	{
		L->data[i] = arr[i];
	}
	L->length = 0;
}
void InitSeqList(SList* L)
{
	L = (SList*)malloc(sizeof(SList));
	L->length = 0;
}
void InitSeqList(SList* L)
{
	L = (SList*)malloc(sizeof(SList));
	L->length = 0;
}
void DestroyList(SList* &L)
{
	free(L);
}
void DestroyList(SList* L)
{
	free(L);
}
bool ListEmpty(SList* L)
{
	return (L->length == 0);
}
void DispList(SList* L)
{
	for (int i=0;i<L->length;i++)
	{
		printf("%c", L->data[i]);
	}
	printf("\n");
}
bool GetElem(SList* L,int i,DataType e)
{
	if (i<1 || i>L->length)
		return false;
	e = L->data[i];
	return true;
}
int LocateElem(SList* L,DataType e)
{
	int i = 0;
	while (i<L->length && L->data[i]!=e)
	{
		i++;
	}
	if (i >= L->length)
		return 0;
	else
		return i + 1;
}
bool GetElem(SList* L,int i,DataType e)
{
	int i = 0;
	while (i < L->length && L->data[i] != e)
		i++;
	if (i >= L->length)
		return false;
	else
		return i + 1;
}
int LocateElem(SList* &L,DataType e)
{
	int i = 0;
	while (i<L->length)
	{
		if (L->data[i] == e)
		{
			return i + 1;
		}
		i++;
	}
	return false;
}
bool ListInsert(SList* L,DataType e)
{
	int i = 0;
	if (i<1 || i>L->length + 1 || L->length == MAX_SIZE)
	{
		return false;
	}
	i--;
	for (int j=L->length-1;j>i;j--)
	{
		L->data[j + 1] = L->data[j];
	}
	L->data[i] = e;
	L->length++;
	return true;
}
bool EraseList(SList* &L,int pos,DataType &e)
{
	if (pos<1 || pos>L->length)
		return false;
	int i = pos;
	while (i<L->length)
	{
		L->data[i - 1] = L->data[i];
	}
	e = L->data[i];
	L->length--;
	return true;
}